var http = require("http");
var url = require("url");

var app = http.createServer(function(request,response){
    response.setHeader('Content-type','text/plain');
    response.setHeader('Access-Control-Allow-Origin','*');

    console.log(request.url);




    var url_json = url.parse(request.url);
    var url_str = JSON.stringify(url_json);

    console.log(url_json.pathname);

    if(url_json.pathname==="/get"){
        var getdata = url_json.query;

        response.write(getdata);
    }

    response.write(url_str);
    response.end();






}).listen(63347,function(){
    console.log("Server running at http://127.0.0.1:63347");
});


/*
*
* listen中的内容什么时候执行
* 如何返回数据：应该设置怎样的报头
* url模块的作用
* response中的write/end方法如何使用
* setHeader Access-control-allow-origin 作用
*
* */